<%@ Register TagPrefix="WorkFlow" TagName="Action" Src="/Manager/Menu/Common/Action.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title id="title" runat="server"></title>
<META HTTP-EQUIV="Expires" content="-1">
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
<LINK rel="stylesheet" type="text/css" href="/CSS/Outlook.css">
<LINK rel="stylesheet" type="text/css" href="/CSS/navbar.css">
<LINK rel="stylesheet" type="text/css" href="/Manager/CSS/CSS.css">
<?XML:NAMESPACE PREFIX="WM">
<?XML:NAMESPACE PREFIX="MYTREE">
<?XML:NAMESPACE PREFIX="TOOL">
<?XML:NAMESPACE PREFIX="DIMOK">
<?IMPORT NAMESPACE="WM"     IMPLEMENTATION="/Include/HTC/dropmenu.htc" >
<?IMPORT NAMESPACE="MYTREE" IMPLEMENTATION="/webctrl_client_d/1_0/treeview.htc" >
<?IMPORT NAMESPACE="DIMOK"  IMPLEMENTATION="/Include/HTC/SendToMenu.htc" >
<?IMPORT NAMESPACE="DIMOK"  IMPLEMENTATION="/Include/HTC/Events.htc" >
<STYLE>
TOOL\:TIP   {behavior: url(/include/HTC/cooltip_js.htc)}
.coolbutton {behavior: url(/include/HTC/coolbutton_js.htc)}
.rowover {behavior: url(/include/HTC/rowover_js.htc)}
#legend {BEHAVIOR: url(/Include/HTC/Toggle.htc)}
.border{border:1px solid black}
.noborder{border:0px solid black}
.margin{MARGIN: 1px}
.msgPopUp{font-family:monospace;font-size:8pt;padding-bottom:2px}
.msgBody{background-color:white;border:1px solid black}
.popUp{border: 1px black solid;}
U{color:darkred}
IMG.transp {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50);VERTICAL-ALIGN: middle}
</STYLE>
<SCRIPT language="javascript" src="/Include/Common.js"></SCRIPT>
<SCRIPT language="javascript" src="/Include/DropMenu.js"></SCRIPT>
<SCRIPT language="javascript" src="/Include/SOAP.js"></SCRIPT>
<SCRIPT language="javascript" src="/Include/Events.js"></SCRIPT>
<SCRIPT language="javascript" src="/Manager/Common/Events.js"></SCRIPT>
<SCRIPT language="javascript" src="/Include/XML.js"></SCRIPT>
<SCRIPT language="javascript" src="/Include/RDS.js"></SCRIPT>
<SCRIPT language="javascript" src="/Include/Tree.js"></SCRIPT>
<SCRIPT language="javascript" src="Common/Tree.js"></SCRIPT>
<SCRIPT language="javascript">
var CLICK_TITLE = "<U>Click</U> - OPEN\n<U>Click Again</U> - MAXIMIZE\n<U>SHIFT-Click</U> - New Window\n<U>Right-CLick</U> - "
function setFrameHeight(){}
//****** UIs ******
function overImage(img){}
function outImage(img){}
function setMsgCoolTip(img){}
</SCRIPT>
</HEAD>
<body MS_POSITIONING="GridLayout" scroll="no" onload="page_Load()" onmousemove="_gx_=event.x;_gy_=event.y" bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0">
<DIV id="ws"></DIV>
<XML id="xmlVerParents"></XML>
<XML id="xmlVerItem"></XML>
<TOOL:TIP id="toolTip" element="divDimok" avoidmouse="true" width="100%" delay="500" duration="20" style="font:menu"></TOOL:TIP>
<TABLE width="100%" height="100%" cellpadding="0" cellspacing="1" border="0">
	<TR valign="top">
		<TD style="background-color:ivory" width="0%" nowrap oncontextmenu="if(event.ctrlKey)return true;return showVerTreeMenu()" rowspan="3">
			<DIV id="divTreeFilter" style="BORDER: black 1px solid;LEFT: -100px;POSITION: absolute; TOP: 1px;display:none" onclick="triggerMsgFilter(event.srcElement)">
				<IMG src="images/MsgFilter0.gif" msgNumber="1" id="chkMsgToDealer" checked="" class="transp" style=""><BR>
				<IMG src="images/MsgFilter0.gif" msgNumber="2" id="chkMsgToBoss" checked="" class="transp"><BR>
				<IMG src="images/MsgFilter0.gif" msgNumber="4" id="chkMsgToVer" checked="" class="transp">
				<!--<BR><IMG src="images/MsgFilter_0.gif" msgNumber="8" id="chkMsgToSelf" checked="" class="transp">-->
			</DIV>
			<DIV id="divVerTree" runat="server" onresize="showTreeFilter(this)"
					 style="overflow-Y:auto;height:100%;margin-left:0px;margin-right:0px"
					 onmousemove1="try{scrollVerList()}catch(e){}" onmouseout1="//debugger;doVerScroll()">
				<DIV style="BEHAVIOR: url(/Include/HTC/Toggle.htc)" imgMarginLeft="0" imgMarginRight="0"></DIV>
				<MYTREE:TREEVIEW ID="oTree" CHILDTYPE="All"	oncheck="checkVerItem()" SELECTEDNODEINDEX="100000"
						DEFAULTSTYLE="FONT-WEIGHT: bold; FONT-SIZE: 75%; FONT-FAMILY: Tahoma"
						SELECTEDSTYLE="COLOR:NAVY;BACKGROUND-COLOR:transparent"
						SYSTEMIMAGESPATH="/webctrl_client/1_0/TreeImages/">
					<ASP:LITERAL ID="ltrTree" Runat="server"></ASP:LITERAL>
				</MYTREE:TREEVIEW>
			</DIV>
		</TD>
		<TD class="pan" width="0%" oncontextmenu="return false" valign="top" height="1%">
			<DIV style="font-weight:bold;color:black;PADDING-BOTTOM:2px;height:1%">
				<!-- StateFlow here -->
				<form id="mainForm" RunAt="server">
<asp:ScriptManager ID="AtlasSM" EnablePageMethods="true" AsyncPostBackTimeout="600" EnablePartialRendering="true" runat="server"/>
				<asp:FormView DataSourceID="dsLoanInfo" runat="server"><ItemTemplate>
				<UI:LoanStatus StatusFromID='<%#Eval("StatusID")%>' WSMethod="LoanStatus" runat="server" />
				<FIELDSET><LEGEND id="legend"><LABEL style="color:White">Verification</LABEL></LEGEND>
					<UI:LoanStatus StatusFromID='<%#Eval("VerificationStatusID")%>' WSMethod="VerificationStatus" DataFld="VerificationStatusID" runat="server" />
				</FIELDSET>
				<FIELDSET><LEGEND id="legend"><LABEL style="color:White">Collection</LABEL></LEGEND>
					<UI:LoanStatus runat="server" DataFld="CollectionStatusID"
							StatusFromID='<%#Eval("CollectionStatusID")==DBNull.Value?0:Eval("CollectionStatusID")%>' WSMethod="CollectionStatus" />
				</FIELDSET>
				<FIELDSET><LEGEND id="legend"><LABEL style="color:White">Repossession</LABEL></LEGEND>
					<UI:LoanStatus runat="server" DataFld="StatusID_Repo"
							StatusFromID='<%#Eval("StatusID_Repo")==DBNull.Value?0:Eval("StatusID_Repo")%>' WSMethod="RepoStatus" />
				</FIELDSET>
				<FIELDSET><LEGEND id="legend"><LABEL style="color:White">Bankruptcy</LABEL></LEGEND>
					<UI:LoanStatus runat="server" DataFld="StatusID_BK"
							StatusFromID='<%#Eval("StatusID_BK")==DBNull.Value?0:Eval("StatusID_BK")%>' WSMethod="BKStatus" />
				</FIELDSET>
				<FIELDSET><LEGEND id="legend"><LABEL style="color:White">Buy Back</LABEL></LEGEND>
					<UI:LoanStatus runat="server" DataFld="StatusID_BuyBack"
							StatusFromID='<%#Eval("StatusID_BuyBack")==DBNull.Value?0:Eval("StatusID_BuyBack")%>' WSMethod="BuyBackStatus" />
				</FIELDSET>
				</ItemTemplate></asp:FormView>
				</form>
				<DS:LoanInfosDataSource ID="dsLoanInfo" runat="server">
					<SelectParameters>
						<asp:ControlParameter Name="LoanID" PropertyName="LoanID" Type="Int32" />
					</SelectParameters>
				</DS:LoanInfosDataSource>
				<DIV class="coolbutton" onclick="showVerFax()" style="width:100%;padding:2px" nowrap="true" id="divFaxToDealer" runat="server">
					<IMG onmouseover="//loadMenuFaxHist()" src="/images/buttons/Print.gif" hspace="5" style="VERTICAL-ALIGN: middle" WIDTH="16" HEIGHT="16">
					Fax to Broker
				</DIV>
				<DIV id="divDragImages" runat="server" class="coolbutton" onclick="showImages()" style="width:100%;padding:2px" align="center" valign="middle">
					Drag Images
				</DIV>
				<DIV align="left">
					<TABLE width="100%" cellpadding="0" cellspacing="0" style="font-weight:bold;color:infobackground">
					<TR><TD colspan="2">Applicant: <SPAN datasrc="#XmlLoanInfo" datafld="ApplicantID"></SPAN></TD></TR>
					</TABLE>
				</DIV>
				<SELECT id="selProcessor" runat="server" datasrc="#XmlLoanInfo" datafld="LoanProcessorUN"></SELECT>
				<SPAN style="display:none"><SPAN style= "COLOR: infobackground">Refresh</SPAN> <INPUT type="checkbox" id="chkRefreshList" checked style="BORDER-STYLE: none" onfocus="this.blur()"> <SPAN style="COLOR: black;" checked></SPAN>
			</DIV>
		</TD>
		<TD valign="top" id="elIfrmPageParent" class1="pan" style="width:100%;height:100%;" rowspan="3">
			<IFRAME id="ifrmImage" src  frameborder="1" height="50%" style="width:100%" zIndex="-1000" onload="//setFrameHeight()" onreadystatechange="setFrameHeight()"></IFRAME>
			<IFRAME id="ifrmInterface" src frameborder="1" height="50%" zIndex="-1000" style="width:100%" onload="//setFrameHeight()" onreadystatechange="setFrameHeight()"></IFRAME>
		</TD>
	<TR>
		<TD valign="top" bgcolor="Gray" runat="server" id="tdImages" height="1%">
			<DIV id="divImageList" align="center" class="raised" style="padding-bottom:5px" oncontextmenu="return false">
				<TABLE datasrc1="#xmlImages" id="tblImages" class="rowover" selectable="1" cellpadding="0" cellspacing="0" width="100%" style="font-weight:bold;font-size:75%;color:cornsilk">
					<TR>
						<TD style="display:none"><SPAN datafld="ID"></SPAN></TD>
						<TD style="display:none"><SPAN datafld="Description"></SPAN></TD>
						<TD 
								onclick="showImage(this)"
								onmouseover="this.over=true;showTitle(this)"
								onmouseout="this.over=false"
								oncontextmenu="showImage(this,true);return false"
								ondblclick="showImage(null,true);event.cancelBubble=true"
								onselectstart="event.cancelBubble=true;return false;">
							<SPAN id="spnImage" datafld="ImageType" style="white-space:nowrap;text-overflow:ellipsis;overflow:hidden;padding-left:0px"></SPAN>
						</TD>
					</TR>
				</TABLE>
			</DIV>
		</TD>
	<TR>
		<TD valign="top" bgcolor="DimGray" runat="server" id="tdPages">
			<DIV id="divPageList" class="raised" style="overflow-y:auto;height:100%;font-weight:bold">
				<TABLE datasrc="#xmlPages" onreadystatechange="if(readyState=='complete'){spnImage.style.width=clientWidth+'px';tblImages.dataSrc='#xmlImages';}" class="rowover" selectable="1" cellpadding="0" cellspacing="0" width="100%" style="font-weight:bold;color:moccasin">
					<TR>
						<TD style="display:none"><SPAN datafld="PageURL"></SPAN></TD>
						<TD style="display:none"><SPAN datafld="PageID"></SPAN></TD>
						<TD onclick="showPage(this)"
								onmouseover="this.coolTip=CLICK_TITLE+'UPPER FRAME';//toolTip.element=this"
								oncontextmenu="showPage(this,true);return false"
								ondblclick="showPage(null,true);event.cancelBubble=true"
								onselectstart="event.cancelBubble=true;return false;">
							<SPAN datafld="PageDesc" style="padding-left:5px"></SPAN>
						</TD>
					</TR>
				</TABLE>
			</DIV>
		</TD>
	</TR>
</TABLE>
<XML id="XmlLoanInfo">
	<ASP:LITERAL ID="ltrLoanInfo" Runat="server"></ASP:LITERAL>
</XML>
<XML id="xmlImages">
	<ASP:LITERAL ID="ltrImages" Runat="server"></ASP:LITERAL>
</XML>
<XML id="xmlImages_All">
	<ASP:LITERAL ID="ltrImages_All" Runat="server"></ASP:LITERAL>
</XML>
<XML id="xmlPages">
	<ASP:LITERAL ID="ltrPages" Runat="server"></ASP:LITERAL>
</XML>
<XML id="xmlVI">
	<ASP:LITERAL ID="ltrVI" Runat="server"></ASP:LITERAL>
</XML>
<XML id="xmlManager">
	<ASP:LITERAL ID="ltrManager" Runat="server"></ASP:LITERAL>
</XML>
<XML id="xmlStipsHist"></XML>
<DIMOK:EVENTS id="events" onReloadVerTree="filterTree()" />
</body>
</HTML>
<SCRIPT language="javascript">
var VERIFYER;
var EMPTY_URL = "about:blank";
var SERVICE_NOT_AVAILIBLE = "Sorry!\nPage is still loading.\n\nPlease, try again later.";
var SRV_NAME = "Tree";
var popUp = createPopup();
//DELETE//attachToSendToMenu(loadImagesList,applID);
//setInterval("setFrameHeight()",1000);
function page_Load(){
	var pageID = getParam("PageID");
	if( pageID )showPage(rsFind(xmlPages.recordset,"PageID",pageID,"PageUrl"));
	attachToReloadVerTree(getVerificationTree,ApplID());
	//ws.useService("Tree.asmx?WSDL&ApplID="+applID,SRV_NAME);
	initInputs();
	showTreeFilter(divVerTree);
}
function SE(el){var r = el.document.body.createTextRange();r.moveToElementText(el); r.select();}
function loadImagesList(){
	var ret = WS(function(ret){_cb(ret)},"XmlImages");
	function _cb(ret){
		if( showSOAPError(ret) )return;
		xmlImages.loadXML(ret.value);
	}
}
// ***** Messages To ...
function showTreeFilter(el){return;divTreeFilter.style.left = divVerTree.clientWidth-divTreeFilter.offsetWidth;}
function triggerMsgFilter(img,cancelEvent){
	if( !img )return;
	img.checked = img.checked ? "" : "1";
	img.src = img.checked ? img.src.replace("0.gif",img.msgNumber+".gif") : img.src.replace(img.msgNumber+".gif","0.gif");
	if( !cancelEvent ) filterTree(false,img);
}
function filterTree(thread,img){//debugger;
	if( !thread )return filterTree.proc = setTimeout(function(){filterTree(true,img)},clearTimeout(filterTree.proc)||1500);
	var msgsNumber = !!chkMsgToDealer.checked*1+!!chkMsgToBoss.checked*2+!!chkMsgToVer.checked*4;//+!!chkMsgToSelf.checked*8;
	return WS(function(ret){_cb(ret)},"VerificationTree",msgsNumber);
	// Locals
	function _cb(ret){
		if( showSOAPError(ret) )return;
		//if( ret.value.match("^<[^<>]+\/>$") ){
			//alert("There is no entries for this filter!");
		//	return triggerMsgFilter(img,true);
		//}
		oTree.innerHTML = '<MYTREE:TREENODETYPE TYPE="All"/><MYTREE:TREENODETYPE TYPE="Checked"/>'+ret.value;
		oTree.oncontentready();
	}
}
// *************************
function loadMenuFaxHist(){
	var ret = WS(CO("StipsHist"));
	if( showSOAPError(ret) )return;
	if( !xmlStipsHist.loadXML(ret.value) )return alert("Error in Stips History Dataset.");
	var rs = xmlStipsHist.recordset;
	var dm = new DropMenu("mnuStipsHist");
	for( rs.MoveFirst(); !rs.EOF; rs.MoveNext() )
		dm.add(rs("Date").value+" "+rs("UserName").value,"showStipHist("+rs("ID").value+")");
	dm.show();
}
function showStipHist(faxHistID){
	open("../Common/FaxHistory.aspx?FaxHistID="+faxHistID);
}
function imageOver(img){
	overImage(img);setMsgCoolTip(img);toolTip.element=img;event.cancelBubble=true;return false;
}
function setFrameHeight(thread){
	if( !thread ){
		clearTimeout(setFrameHeight.proc);
		return setFrameHeight.proc = setTimeout("setFrameHeight(true)",500);
	}
var height = !noSrc(ifrmImage) && !noSrc(ifrmInterface)?"50%":"100%";
	try{ifrmImage.frameElement.height = noSrc(ifrmImage)?'0%':height;
	}catch(e){}
	try{ifrmInterface.frameElement.height = noSrc(ifrmInterface)?'0%':height;
	}catch(e){}
}
function noSrc(frame){
	try{
	return !(frame.location+'') || frame.location == EMPTY_URL || !frame.location.href;
	}catch(e){ return true	}
}
function showVerTreeMenu(){
	var dm = new DropMenu("mnuFly");
	if( !dm.menuID )return false;
	dm.add("Add Item" ,"addVerItem(ce)" ,"Images/Menu/Lamp.gif");
	if( copyVerItem.id )dm.add("Paste" ,"pasteVerItem()");
	dm.menuShow(_gx_,_gy_);
	event.cancelBubble = true;
	return false;
}
function showNodeMenu(){
	var dm = new DropMenu("mnuFly");
	if( !dm.menuID )return false;
	var node = _treeNodeXML(event.srcElement);
	dm.add("Item History","showVerItemHist(ce,"+_gx_+","+_gy_+")","Images/Menu/History.gif");
	dm.add("-");
	dm.add("Edit Item","editVerItem(ce)","Images/Menu/Edit.gif");
	dm.add("Add Item" ,"addVerItem(ce)" ,"Images/Menu/Lamp.gif");
	dm.add("Add Child" ,"addVerItem(ce,true)" ,"Images/Menu/Tree_Little.gif");
	dm.add("Move Up" ,"moveVerItem(ce,-1)" ,"Images/Menu/PointUp.gif");
	dm.add("Move Down" ,"moveVerItem(ce,1)" ,"Images/Menu/PointUp.gif");
	dm.add("Level Up" ,"levelVerItem(ce)" ,"Images/Menu/PointUp.gif");
	if( !_IsCustom(node) ){
		dm.add("-");
		dm.add(_bold("Cut",copyVerItem.cut) ,"copyVerItem(ce,true)");
		dm.add(_bold("Copy",!copyVerItem.cut) ,"copyVerItem(ce)");
		if( copyVerItem.id ){
			dm.add("Paste" ,"pasteVerItem(ce)");
			dm.add("Paste as <B>child</B>" ,"pasteVerItem(ce,true)");
		}
	}
	dm.add("-");
	dm.add("Delete Item" ,"deleteVerItem(ce)" ,"Images/Menu/KeyPress.gif");
	dm.menuShow(_gx_,_gy_);
	event.cancelBubble = true;
	return false;
	function _bold(text,bold){return (bold?"<B>":"")+text+(bold?"</B>":"");}
}
function showVerFax(){
	showIFrame(ifrmImage,EMPTY_URL);
	showIFrame(ifrmInterface,"FaxToBroker.aspx?ApplID="+ApplID())
	//showIFrame(ifrmInterface,!menuItem?"Verification_FaxToDealer.htm":getLocation()+"?faxStipsToDealerHTML("+menuItem.all.spnDateValue.innerText+")")
}
function makeEditMessageXml(id,commentToBroker,commentToVer,commentToVerHist,commentToSelf){
	return makeXML({id:id,CommentToBroker:commentToBroker,CommentToVerifier:commentToVer,CommentToVerifierHist_Local:commentToVerHist,CommentToSelf:commentToSelf,ManagerTo:""});
}
function messageToBroker(img){
	var node = _treeNodeXML(img);
	var oParams =
		{xmlRS:makeEditMessageXml(_id(node),_CommentToBroker(node)||"",_CommentToVerifier(node)||"",_CommentToVerifierHist(node)||"",_CommentToSelf(node)||""),
		 rsManagers:xmlManager.recordset,
		 cb:_saveComments,
		 self:VERIFYER
		};
	showModelessDialog("Common/MsgToDealer.htm",oParams,"help:0;status:0");
	// Locals
	function _saveComments(w){
		if( !w )return;
		var ret = WS(CO("UpdateVerInfo"),w);
		if( showSOAPError(ret) )return false;
		var rsComments = getRSfromDS(ret.value);
		_CommentToSelf(node,rsComments);
		_CommentToBroker(node,rsComments);
		_DescToBroker(node,rsComments);
		_CommentToVerifierHist(node,rsComments);
		setCheckBox(rsComments("ID").value,eval(rsComments("Checked").value));
		img.src = rsComments("EnvelopUrl").Value;
		_imgMsgs(img).src = rsComments("MsgsUrl").Value;
	}
}
function deleteVerItem(ce){
	var node = _treeNodeXML(ce);
	if( !confirm("Delete \""+_label(ce)+"\" from the tree?") )return;
	var co = CO("DeleteVerItem");
	var ret = WS(co,_id(node));
	if( showSOAPError(ret) )return;
	fireVerTreeChanged(ApplID());
	filterTree(true);
}
function moveVerItem(ce,dir){
	var node = _treeNodeXML(ce);
	var tabIndex = _TabIndex(node)+dir;
	var xml = makeEditVerItemParams(_id(node),undefined,tabIndex);
	var ret = WS(CO("AddItemInfo"),xml);
	if( showSOAPError(ret) )return;
	filterTree();
}
function levelVerItem(ce){
	var node = _treeNodeXML(ce);
	if( !confirm("Move "+_label(ce)+" one level Up?") )return;
	var ret = WS(CO("LevelItemUp"),_id(node));
	if( showSOAPError(ret) )return;
	filterTree();
}
function copyVerItem(ce,cut){
	var node = _treeNodeXML(ce);
	copyVerItem.id = _id(node);	
	copyVerItem.cut = cut || false;	
}
function pasteVerItem(ce,child){
	var id = ce ? _id(_treeNodeXML(ce)) : 0;
	var ret = WS(CO("CopyItem"),copyVerItem.id,child?id:0,child?0:id,0,copyVerItem.cut);
	if( showSOAPError(ret) )return;
	fireVerTreeChanged(ApplID());
	filterTree();
}
function addVerItem(ce,child){
	var node = _treeNodeXML(ce);
	var parenID = !node ? 0 : child ? _id(node) : _ParentID(node);
	var pos = node ? _TabIndex(node)+1 : 0;
	var u;
	var params = {xmlRS:makeEditVerItemParams(0,parenID,pos,"","","",0,0,0,false,node?_IsCustom(node):0),images:xmlImages_All,pages:xmlPages};
	var w = showModalDialog("Common/NewVerItem.htm",params,"help:0;status:0");
	if( !w )return;
	var ret = WS(CO("AddItemInfo"),w);
	if( showSOAPError(ret) )return;
	fireVerTreeChanged(ApplID());
	filterTree();
}
function makeEditVerItemParams(id,parentID,pos,label,desc,descToBroker,imageID,pageID,menuID,defaultValue,isCustom){
	return makeXML({id:id,parentID:parentID,pos:pos,lable:label,description:desc,descToBroker:descToBroker,imageTypeID:imageID,pageID:pageID,menuID:menuID,defaultValue:defaultValue,IsCustom:isCustom});
}
function editVerItem(ce){
	var node = _treeNodeXML(ce);
	var xmlRS = makeEditVerItemParams(_id(node),undefined,undefined,_label(ce)||"",_Description(node)||"",_DescToBroker(node)||"",_ImageTypeID(node)||0,_PageID(node)||0,undefined,_DefaultValue(node),_IsCustom(node));
	oParams = {xmlRS:xmlRS,images:xmlImages_All,pages:xmlPages};
	var w = showModalDialog("Common/NewVerItem.htm",oParams,"help:0;status:0");
	if( !w )return;
	var ret = WS(CO("AddItemInfo"),w);
	if( showSOAPError(ret) )return;
	var rs = getRSfromDS(w.xml);
	_label(ce,rs("lable").value);
	_Description(node,rs("description").value);
	_DescToBroker(node,rs("descToBroker").value);
	_PageID(node,rs("PageID").value);
	_ImageTypeID(node,rs("ImageTypeID").value);
	_DefaultValue(node,rs("DefaultValue").value);
	_CommentToBroker(node,_DescToBroker(node));
}
function checkBox(chk){
	event.cancelBubble=true;
	var nodeXML = _treeNodeXML(chk);
	var ret = _updateChecked(_id(nodeXML),chk.checked);
	if( !ret )return false;
	xmlVerParents.loadXML(ret.value);
	var rsParents = _findPrentsTable(xmlVerParents.recordset);
	//var nodeObj = oTree.getTreeNode(oTree.getNodeIndex(nodeXML));
	if( rsParents )
		for( rsParents.MoveFirst(); !rsParents.EOF ; rsParents.MoveNext() )
			setCheckBox(rsParents("ID").value,eval(rsParents("Checked").value));
	var rsDone = _findPrentsTable(xmlVerParents.recordset,true);
	if( rsDone ){
		var done = oTree.createTreeNode();
		done.setAttribute("text", "Done");
		var nodeObj = oTree.getTreeNode(nodeXML);
		for( var f = 0; f < rsDone.Fields.Count; f++ )
			done.setAttribute(rsDone.Fields(f).Name,rsDone.Fields(f).Value);
		nodeObj.add(done);
		_expanded(nodeObj,true);
	}
	fireVerTreeChanged(ApplID());
	return true;
	//Locals
	function _findPrentsTable(rs,not){
		if( !rs.State || !rs.recordCount )return null;
		if( _isParentsTable(rs) )return !not ? rs : null;
		for( var f = rs.Fields.Count-2 ; f >= 0; f-- )
			if( !not && _isParentsTable(rs(f).Value) )return rs(f).Value;
			else if( not && !_isParentsTable(rs(f).Value) )return rs(f).Value;
		return null;
	}
	function _isParentsTable(rs){return rs.Fields(0).Name == "ID" && rs.Fields(1).Name == "Checked";}
	function _updateChecked(id,checked){
		var d = new Date();
		status = "_updateChecked Started";
		var ret = WS(CO("UpdateChecked"),id,checked);
		if( showSOAPError(ret) )return;
		status = "_updateChecked finished in "+(new Date()-d).valueOf();
		return ret;
	}
}
function setCheckBox(id,checked,noExpandAction){
	var d = new Date();
	var chk = oTree.viewLink.all["chkBox"+id];
	if( !chk ) return false;
	_labelSPAN(chk).style.color = checked ? "darkgreen" : "darkred";
	_checked(chk,checked);
	var nodeXML = _treeNodeXML(chk);
	if( !noExpandAction )_expanded(oTree.getTreeNode(nodeXML),!chk.checked);
	var imgIndex = !!_CommentToBroker(nodeXML)*1 + !!_CommentToVerifierHist(nodeXML)*2 + !!_CommentToSelf(nodeXML)*4;
	var imgMsgs = _imgMsgs(chk);
	imgMsgs.src = imgMsgs.src.replace(/(.+)(\d)(.+?)$/,"$1"+imgIndex+"$3");	
	return true;
	//_expanded(oTree.getTreeNode(oTree.getNodeIndex(nodeXML)),!chk.checked)
}
function checkVerItem(){debugger;
	event.cancelBubble=true;
	var node = oTree.getTreeNode(event.treeNodeIndex);
	if( !WS ){
		_checked(node,!_checked(node));
		return alert(SERVICE_NOT_AVAILIBLE);
	}
	//return alert("treeNodeIndex:"+nodeIndex+",checked:"+_checked(node));
	var checked = !_checked(node);
	//if( _isSmart(node) )return _checked(node,!_checked(node,checked));
	//_checked(node,checked);
	var id = node.getAttribute("ID");
	//debugger;
	var ret = _updateChecked(id,checked);
	if( !ret )return false;
	xmlVerParents.loadXML(ret.value);
	var rs = xmlVerParents.recordset;
	for( rs.MoveFirst(); node = node.getParent(); rs.MoveNext() ){
		checked = eval(rs(1).value);
		//_checked(node,checked);
		//_expanded(node,!checked);
	}
	return true;
	//Locals
	function _updateChecked(id,checked){
		var co = CO("UpdateChecked");
		var ret = WS(co,id,checked);
		if( showSOAPError(ret) )return;
		return ret;
	}
}
function sendToMenu_DeleteMe(){
	if( !WS)return alert(SERVICE_NOT_AVAILIBLE);
	if( !confirm("Send applicant to "+event.menuName) )return;
	var co = CO("SendToMenu");
	var ret = WS(co,event.menuID);
	if( showSOAPError(ret) )return;
	if( chkRefreshList.checked )fireSendToMenu();
	closeUs();
}
function getVerificationTree(eventObject){//debugger;
	if( eventObject.reload )return filterTree(true);
	var ret = WS(cb,"VerificationItems");
	///Local
	function cb(ret){
		if( showSOAPError(ret) )return;
		var XML_RS = "XML_RS_VER_ITEMS";
		var xml = document.all[XML_RS];
		if( !xml ){
			document.body.insertAdjacentHTML("beforeEnd","<xml id='"+XML_RS+"'></xml>");
			xml = document.all[XML_RS];
		}
		xml.loadXML(ret.value);
		var rs = xml.recordset;
		for( rs.MoveFirst(); !rs.EOF ; rs.MoveNext() )
			setCheckBox(rs("ID").value,eval(rs("Checked").value),true);
	}
}
//****** UIs ******
function overImage(img){
	img.style.border = "1px solid black";
	img.style.margin = "";
	img.onmouseout = function(){outImage(this)}
}
function outImage(img){
	img.style.border = "";
	img.style.margin = "1px";
}
function setMsgCoolTip(img){
	var node = _treeNodeXML(img);
	var coolTip = _CommentToBroker(node)?'Message To Broker:<div class=\'msgBody\'>'+_CommentToBroker(node).replace('"','\'\'')+'</div>' : "";
	coolTip += _CommentToManager(node)?'Message To Manager:<div class=\'msgBody\'>'+_CommentToManager(node).replace('"','\'\'')+'</div>' : "";
	coolTip += _CommentToVerifier_ALL(node)?'Message From Manager:<div class=\'msgBody\'>'+_CommentToVerifier_ALL(node).replace('"','\'\'')+'</div>' : "";
	coolTip += _CommentToSelf(node)?'Message To '+VERIFYER+':<div class=\'msgBody\'>'+_CommentToSelf(node).replace('"','\'\'')+'</div>' : "";
	img.coolTip = coolTip ? '<div class=\'msgPopUp\'>'+coolTip+'</div>' : "";
}
//****** Helpers ******
function makeXML(fields){
	var xml = new ActiveXObject("Microsoft.XMLDOM");
	var root = xmlAddElement(xml,"TABLE");
	xmlAddElement(root,"RS",fields);
	return xml;
}
//****** Properties
	// ***** XML *****
function _isSmart(node){return node.getAttribute("IsSmart")==0?false:true;}
function _checkedXML(node,value){
	alert("_checkedXML(...) is not supposed to be called.");
	if( arguments.length > 1 ){
		node.all.chkBox.checked = value;
		//_type(node,value?"checked":"all");
	}
	return node.all.chkBox.checked;
	//return __getAttr(node,value)
}
function _label(el,value){
	if( arguments.length > 1 )try{el.innerHTML = value}catch(e){el.innerText = value};
	return el.innerHTML;
}
function _treeNodeText(el){
	return getParentByAttrEx(el,"id","_tntext");
}
function _imgMsgs(el){
	return _treeNodeText(el).all.imgMsgs||{src:""};
}
function _labelSPAN(el){
	return _treeNodeText(el).all.spnNodeLable;
}
function _CommentToManager(node,value){return __getAttr(node,value)}
function _CommentToSelf(node,value){return __getAttr(node,value)}
function _CommentToBroker(node,value){return __getAttr(node,value)}
function _CommentToVerifier(node,value){return __getAttr(node,value)}
function _CommentToVerifierHist(node,value){return __getAttr(node,value)}
function _CommentToVerifier_ALL(node,value){return trim((_CommentToVerifier(node,value)||"")+"\n"+(_CommentToVerifierHist(node,value)||""))}
function _DescToBroker(node,value){return __getAttr(node,value)}
function _Description(node,value){return __getAttr(node,value)}
function _DefaultValue(node,value){return __getAttr(node,value)}
function _IsCustom(node,value){return eval(__getAttr(node,value))}
// ***** FSB *****
function deleteFromFSB(){
	var ret = WS(CO("FSB_Delete"));
	if( showSOAPError(ret) )return;
	fireSendToMenu();
	top.close();
}
</SCRIPT>
